<script type="text/javascript">
	var asInitVals = new Array();
	$(document).ready(function() {
		var oTable = $('#data').dataTable({
			"bJQueryUI": true,
			"sPaginationType": "full_numbers",
			"aaSorting": [ [1,'asc'] ],
			"sDom": 'T<"H"lfr>t<"F"ip>',
			"oTableTools": {
				"aButtons": [
				{
					"sExtends": "copy",
					"sButtonText": "Copiar",
					"mColumns": [0, 1, 2, 3]
				},
				{
					"sExtends": "print",
					"sButtonText": "Imprimir"
				},
				{
					"sExtends":    "collection",
					"sButtonText": "Guardar como",
					"aButtons":    [
						{
							"sExtends": "xls",
							"mColumns": [0, 1, 2, 3]
						},
						{
							"sExtends": "pdf",
							"sPdfOrientation": "landscape",
							"mColumns": [0, 1, 2, 3],
							"sPdfMessage": "Lista de Tiendas"
						}
					]
				}
			]
			}
        });

        $("tfoot input").keyup( function () {
        	oTable.fnFilter( this.value, $("tfoot input").index(this) );
    	});

		$("tfoot input").each( function (i) {
        	asInitVals[i] = this.value;
    	} );
     
    	$("tfoot input").focus( function () {
        	if ( this.className == "search_init" )
        	{
            	this.className = "";
            	this.value = "";
        	}
    	});
     
    	$("tfoot input").blur( function (i) {
        	if ( this.value == "" )
        	{
            	this.className = "search_init";
            	this.value = asInitVals[$("tfoot input").index(this)];
        	}
    	});
    });
</script>
<a href="../Tiendas/nuevo" class="DTTT_button ui-state-default" style="float:right; margin-bottom:7px;">
	<span>Nueva Tienda</span>
</a>
<table cellpadding="0" cellspacing="0" border="0" class="display" id="data">
    <thead>
        <tr>
			<th>Código</th>
			<th>Tienda</th>
			<th>Ubicacion</th>
			<th>Telefono</th>
			<th>Acciones</th>
        </tr>
    </thead>
    <tbody>
	<?php foreach ($tiendas as $t) { ?>
		<tr>
			<td style="vertical-align:middle;"><?php echo $t['Tienda']['id']; ?></td>
			<td style="vertical-align:middle;"><?php echo $t['Tienda']['nombre']; ?></td>
			<td style="vertical-align:middle;"><?php echo $t['Tienda']['ubicacion']; ?></td>
			<td style="vertical-align:middle;"><?php echo $t['Tienda']['telefono']; ?></td>
			<td style="text-align:center; vertical-align:middle; height:22px;">
				<a class="crud" href="../Tiendas/editar?id=<?php echo $t['Tienda']['id']; ?>"><img title="editar" width="16px" height="16px" src="../css/images/editar.png"></a>
				<a class="crud" href="../Tiendas/borrar?id=<?php echo $t['Tienda']['id']; ?>" onclick="return confirm('Si elimina la tienda también se eliminaran sus ventas');">
					<img title="borrar" width="16px" height="16px" src="../css/images/borrar.png">
				</a>
			</td>
		</tr>
	<?php } ?>
    </tbody>
    <tfoot>
		<tr>
			<th>
				<input type="text" value="Codigo" class="search_init">
			</th>
			<th>
				<input type="text" value="Tienda" class="search_init">
			</th>
			<th>
				<input type="text" value="Ubicacion" class="search_init">
			</th>
			<th>
				<input type="text" value="Telefono" class="search_init">
			</th>
			<th style="text-align: center;">Acciones</th>
		</tr>
	</tfoot>
</table>